  subroutine gpuneedcore(gneed, giop)
  use mod_iop
  use mod_size
  use mod_orbit
  use mod_ioff
  use mod_ri
  use mod_symm
  implicit none
  integer, intent(inout) :: gneed(5), giop(5)
  integer i0g, i1g, i2g, i3g, i4g, i5g, i6g, i7g, i8g, i9g, i10g, i11g, i12g, i13g
  integer gsize, nvvo , irrep
  integer, external :: idsymsoc
  nvvo = 1
  do irrep = 1, nirrep 
      nvvo = max(nvvo, idsymsoc(irrep, vrta, vrta, 1, popa, zorb, 1), & 
                   idsymsoc(irrep, vrtb, vrtb, 1, popa, zorb, 1), & 
                   idsymsoc(irrep, vrta, vrta, 1, popb, zorb, 1), & 
                   idsymsoc(irrep, vrtb, vrtb, 1, popb, zorb, 1))
  enddo
!------for calciabci_n5
   giop(1:5) = 0 
   i0g = 1
   i1g = i0g + nifvo*isd
   i2g = i1g + nioi3*isd
   i3g = i2g + nifvo*isd
   i4g = i3g + nioi3*isd
   i5g = i4g + nifvv*isd
   i6g = i5g + nioi4*isd
   i7g = i6g + nioiri_vv*isd
   i8g = i7g + nioiri_vo*isd
   i9g = i8g + nioiri_oo*isd
   i10g = i9g + max(nvvoo*isd*6, (nvvoo*4+nvvv*2)*isd)
   gneed(1) = i10g
   if(gneed(1) < igpusize) then 
      giop(1) = 1 
   elseif(gneed(1) > igpusize) then 
      gneed(1) = max(nioiri_vv1, nioiri_vv2) +& 
                 max(nioiri_vo1, nioiri_vo2) + nvvv*isd*2
      if(gneed(1) < igpusize) then 
         giop(1) = 2
      endif
   endif

   
!------for calciabci
   i0g = 1
   i1g = i0g + nifvo*isd
   i2g = i1g + nioi3*isd
   i3g = i2g + nifvo*isd
   i4g = i3g + nioi3*isd
   i5g = i4g + nioiri_vv*isd
   i6g = i5g + nioiri_vo*isd
   i7g = i6g + nioiri_oo*isd
   i8g = i7g + max(nvvoo*isd*2, nvvv*isd*2)
   gneed(2) = i8g
   if(gneed(2) < igpusize) then 
      giop(2) = 1
   else
      gneed(2) = (nvvv*2 + nvvoo*2 + max(nioiri_vv1, nioiri_vv2) + &
                   max(nioiri_vo1, nioiri_vo2))*isd 
      if(gneed(2)<igpusize) then 
          giop(2) = 2 
      else 
          gneed(2) = (nvvv*2 + nvvo*2 + max(nioiri_vv1, nioiri_vv2) + &
                       max(nioiri_vo1, nioiri_vo2))*isd 
          if(gneed(2)<igpusize) then
              giop(2) = 3 
          endif 
      endif
   endif

!------for calciabcd
   i0g = 1
   i1g = i0g + nifvo*isd
   i2g = i1g + nioi3*isd
   i3g = i2g + nifvo*isd
   i4g = i3g + nioi3*isd
   i5g = i4g + nioiri_vv*isd
   i6g = i5g + max(nvvoo*isd*2, nvvv*isd*2)
   gneed(3) = i6g 
   if(gneed(3) < igpusize) then 
      giop(3) = 1 
   else
      gneed(3) = (nvvv*2 + nvvoo*2 + max(nioiri_vv1, nioiri_vv2))*isd 
      if(gneed(3)<igpusize) then 
          giop(3) = 2 
      else 
          gneed(3) = (nvvv*2 + nvvo*2 + max(nioiri_vv1, nioiri_vv2))*isd 
          if(gneed(3)<igpusize) then
              giop(3) = 3 
          endif
      endif
   endif
!----for wmbej                                                     
   i0g = 1
   i1g = i0g + nifvo*isd
   i2g = i1g + nioi3*isd
   i3g = i2g + nifvo*isd
   i4g = i3g + nioi3*isd
   i5g = i4g + nioi2*isd
   i6g = i5g + nioi3*isd
   i7g = i6g + nioi4*isd
   i8g = i7g + max(nvvoo*isd*5, nvvv*isd*2)
   gneed(4) = i8g
   if(gneed(4) < igpusize) then 
      giop(4) = 1
   else 
      gneed(4) = nvvoo*isd*3
      if(gneed(4) <igpusize) then 
         giop(4) = 2 
      endif 
   endif

!----for left                                                     
   i0g = 1
   i1g = i0g +   nioi2*isd
   i2g = i1g +   nioi3*isd
   i3g = i2g +   nioi4*isd
   i4g = i3g +   nifvo*isd
   i5g = i4g +   nioi3*isd
   i6g = i5g +   nifvo*isd
   i7g = i6g +   nioi3*isd
   i8g = i7g +   nifvv*isd
   i9g = i8g +   nifoo*isd
   i10g = i9g +  nifvo*isd
   i11g = i10g + nioi1*isd
   i12g = i11g + nvvoo*4*isd 
   gneed(5) = i12g
   if(gneed(5) < igpusize) then 
      giop(5) = 1 
   endif
   write(6,*)'gpu memory need for each part' 
   write(6,*)'part 1', gneed(1)*4/1024/1024, 'mb' 
   write(6,*)'part 2', gneed(2)*4/1024/1024, 'mb' 
   write(6,*)'part 3', gneed(3)*4/1024/1024, 'mb' 
   write(6,*)'part 4', gneed(4)*4/1024/1024, 'mb' 
   write(6,*)'part 5', gneed(5)*4/1024/1024, 'mb' 
   return 
  end
 
